home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 204_01 / list.c < prev    next >
Text File  |  1980-01-01  |  5KB  |  142 lines

  1. #include        <stdio.h>
  2. #include        "c.h"
  3. #include        "expr.h"
  4. #include        "gen.h"
  5. #include        "cglbdec.h"
  6.  
  7. /*
  8.  *    68000 C compiler
  9.  *
  10.  *    Copyright 1984, 1985, 1986 Matthew Brandt.
  11.  *  all commercial rights reserved.
  12.  *
  13.  *    This compiler is intended as an instructive tool for personal use. Any
  14.  *    use for profit without the written consent of the author is prohibited.
  15.  *
  16.  *    This compiler may be distributed freely for non-commercial use as long
  17.  *    as this notice stays intact. Please forward any enhancements or questions
  18.  *    to:
  19.  *
  20.  *        Matthew Brandt
  21.  *        Box 920337
  22.  *        Norcross, Ga 30092
  23.  */
  24.  
  25. put_sc(scl)
  26. int     scl;
  27. {       switch(scl) {
  28.                 case sc_static:
  29.                         fprintf(list,"Static      ");
  30.                         break;
  31.                 case sc_auto:
  32.                         fprintf(list,"Auto        ");
  33.                         break;
  34.                 case sc_global:
  35.                         fprintf(list,"Global      ");
  36.                         break;
  37.                 case sc_external:
  38.                         fprintf(list,"External    ");
  39.                         break;
  40.                 case sc_type:
  41.                         fprintf(list,"Type        ");
  42.                         break;
  43.                 case sc_const:
  44.                         fprintf(list,"Constant    ");
  45.                         break;
  46.                 case sc_member:
  47.                         fprintf(list,"Member      ");
  48.                         break;
  49.                 case sc_label:
  50.                         fprintf(list,"Label");
  51.                         break;
  52.                 case sc_ulabel:
  53.                         fprintf(list,"Undefined label");
  54.                         break;
  55.                 }
  56. }
  57.  
  58. put_ty(tp)
  59. TYP     *tp;
  60. {       if(tp == 0)
  61.                 return;
  62.         switch(tp->type) {
  63.                 case bt_char:
  64.                         fprintf(list,"Char");
  65.                         break;
  66.                 case bt_short:
  67.                         fprintf(list,"Short");
  68.                         break;
  69.                 case bt_enum:
  70.                         fprintf(list,"enum ");
  71.                         goto ucont;
  72.                 case bt_long:
  73.                         fprintf(list,"Long");
  74.                         break;
  75.                 case bt_unsigned:
  76.                         fprintf(list,"unsigned long");
  77.                         break;
  78.                 case bt_float:
  79.                         fprintf(list,"Float");
  80.                         break;
  81.                 case bt_double:
  82.                         fprintf(list,"Double");
  83.                         break;
  84.                 case bt_pointer:
  85.                         if( tp->val_flag == 0)
  86.                                 fprintf(list,"Pointer to ");
  87.                         else
  88.                                 fprintf(list,"Array of ");
  89.                         put_ty(tp->btp);
  90.                         break;
  91.                 case bt_union:
  92.                         fprintf(list,"union ");
  93.                         goto ucont;
  94.                 case bt_struct:
  95.                         fprintf(list,"struct ");
  96. ucont:                  if(tp->sname == 0)
  97.                                 fprintf(list,"<no name> ");
  98.                         else
  99.                                 fprintf(list,"%s ",tp->sname);
  100.                         break;
  101.                 case bt_ifunc:
  102.                 case bt_func:
  103.                         fprintf(list,"Function returning ");
  104.                         put_ty(tp->btp);
  105.                         break;
  106.                 }
  107. }
  108.  
  109. list_var(sp,i)
  110. SYM     *sp;
  111. int     i;
  112. {       int     j;
  113.         for(j = i; j; --j)
  114.                 fprintf(list,"    ");
  115.         fprintf(list,"%-10s =%06x ",sp->name,sp->value.u);
  116.         if( sp->storage_class == sc_external)
  117.                 fprintf(output,"\tglobal\t%s\n",sp->name);
  118.         else if( sp->storage_class == sc_global )
  119.                 fprintf(output,"\tglobal\t%s\n",sp->name);
  120.         put_sc(sp->storage_class);
  121.         put_ty(sp->tp);
  122.         fprintf(list,"\n");
  123.         if(sp->tp == 0)
  124.                 return;
  125.         if((sp->tp->type == bt_struct || sp->tp->type == bt_union) &&
  126.                 sp->storage_class == sc_type)
  127.                 list_table(&(sp->tp->lst),i+1);
  128. }
  129.  
  130. list_table(t,i)
  131. TABLE   *t;
  132. int     i;
  133. {       SYM     *sp;
  134.         sp = t->head;
  135.         while(sp != NULL) {
  136.                 list_var(sp,i);
  137.                 sp = sp->next;
  138.                 }
  139. }
  140.  
  141.  
  142.